From def1ee7055c259ea0c8aa732c35fc6291cfa68c4 Mon Sep 17 00:00:00 2001
From: Chris Guimaraes <cguimaraes@hiro.so>
Date: Wed, 27 Nov 2024 12:18:40 +0000
Subject: [PATCH 1/6] chore: add missing functions to ClarityBackingStore trait

---
 clarity/src/vm/database/clarity_store.rs | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/clarity/src/vm/database/clarity_store.rs b/clarity/src/vm/database/clarity_store.rs
index b6a45ee764..37456560ef 100644
--- a/clarity/src/vm/database/clarity_store.rs
+++ b/clarity/src/vm/database/clarity_store.rs
@@ -64,9 +64,15 @@ pub trait ClarityBackingStore {
     fn put_all_data(&mut self, items: Vec<(String, String)>) -> Result<()>;
     /// fetch K-V out of the committed datastore
     fn get_data(&mut self, key: &str) -> Result<Option<String>>;
+    /// fetch Hash(K)-V out of the commmitted datastore
+    fn get_data_from_path(&mut self, hash: &TrieHash) -> Result<Option<String>>;
     /// fetch K-V out of the committed datastore, along with the byte representation
     ///  of the Merkle proof for that key-value pair
     fn get_data_with_proof(&mut self, key: &str) -> Result<Option<(String, Vec<u8>)>>;
+    fn get_data_with_proof_from_path(
+        &mut self,
+        hash: &TrieHash,
+    ) -> Result<Option<(String, Vec<u8>)>>;
     fn has_entry(&mut self, key: &str) -> Result<bool> {
         Ok(self.get_data(key)?.is_some())
     }

From f9fcc57c92bf3a45ccdcfa2c1192c1e9bcc00d78 Mon Sep 17 00:00:00 2001
From: Chris Guimaraes <cguimaraes@hiro.so>
Date: Wed, 27 Nov 2024 13:24:44 +0000
Subject: [PATCH 2/6] chore: add missing dependency

---
 clarity/src/vm/database/clarity_store.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clarity/src/vm/database/clarity_store.rs b/clarity/src/vm/database/clarity_store.rs
index 37456560ef..92804106fb 100644
--- a/clarity/src/vm/database/clarity_store.rs
+++ b/clarity/src/vm/database/clarity_store.rs
@@ -18,7 +18,7 @@ use std::path::PathBuf;
 
 #[cfg(feature = "canonical")]
 use rusqlite::Connection;
-use stacks_common::types::chainstate::{BlockHeaderHash, StacksBlockId, VRFSeed};
+use stacks_common::types::chainstate::{BlockHeaderHash, StacksBlockId, TrieHash, VRFSeed};
 use stacks_common::util::hash::{hex_bytes, to_hex, Hash160, Sha512Trunc256Sum};
 
 use crate::vm::analysis::AnalysisDatabase;

From ef3ef6759b94c69284a7f21da378f27bd051b1f8 Mon Sep 17 00:00:00 2001
From: Chris Guimaraes <cguimaraes@hiro.so>
Date: Wed, 27 Nov 2024 13:52:47 +0000
Subject: [PATCH 3/6] chore: add missing trait functions implementations

---
 clarity/src/vm/database/clarity_store.rs | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/clarity/src/vm/database/clarity_store.rs b/clarity/src/vm/database/clarity_store.rs
index 92804106fb..07d48c9504 100644
--- a/clarity/src/vm/database/clarity_store.rs
+++ b/clarity/src/vm/database/clarity_store.rs
@@ -215,10 +215,21 @@ impl ClarityBackingStore for NullBackingStore {
         panic!("NullBackingStore can't retrieve data")
     }
 
+    fn get_data_from_path(&mut self, _hash: &TrieHash) -> Result<Option<String>> {
+        panic!("NullBackingStore can't retrieve data")
+    }
+
     fn get_data_with_proof(&mut self, _key: &str) -> Result<Option<(String, Vec<u8>)>> {
         panic!("NullBackingStore can't retrieve data")
     }
 
+    fn get_data_with_proof_from_path(
+        &mut self,
+        _hash: &TrieHash,
+    ) -> Result<Option<(String, Vec<u8>)>> {
+        panic!("NullBackingStore can't retrieve data")
+    }
+
     #[cfg(feature = "canonical")]
     fn get_side_store(&mut self) -> &Connection {
         panic!("NullBackingStore has no side store")

From 5b3ac9d05e49acfcb79ee49593e9237a6670e777 Mon Sep 17 00:00:00 2001
From: Chris Guimaraes <cguimaraes@hiro.so>
Date: Wed, 27 Nov 2024 14:05:36 +0000
Subject: [PATCH 4/6] chore: add missing trait functions implementations

---
 clarity/src/vm/database/sqlite.rs        | 11 +++++++++++
 stackslib/src/clarity_vm/database/mod.rs | 14 ++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/clarity/src/vm/database/sqlite.rs b/clarity/src/vm/database/sqlite.rs
index 7d2af59eb5..3d72a1b0fe 100644
--- a/clarity/src/vm/database/sqlite.rs
+++ b/clarity/src/vm/database/sqlite.rs
@@ -324,10 +324,21 @@ impl ClarityBackingStore for MemoryBackingStore {
         SqliteConnection::get(self.get_side_store(), key)
     }
 
+    fn get_data_from_path(&mut self, hash: &TrieHash) -> Result<Option<String>> {
+        SqliteConnection::get(self.get_side_store(), hash.to_string().as_str())
+    }
+
     fn get_data_with_proof(&mut self, key: &str) -> Result<Option<(String, Vec<u8>)>> {
         Ok(SqliteConnection::get(self.get_side_store(), key)?.map(|x| (x, vec![])))
     }
 
+    fn get_data_with_proof_from_path(
+        &mut self,
+        hash: &TrieHash,
+    ) -> Result<Option<(String, Vec<u8>)>> {
+        self.get_data_with_proof(&hash.to_string())
+    }
+
     fn get_side_store(&mut self) -> &Connection {
         &self.side_store
     }
diff --git a/stackslib/src/clarity_vm/database/mod.rs b/stackslib/src/clarity_vm/database/mod.rs
index 44eeaa2e07..5f97985394 100644
--- a/stackslib/src/clarity_vm/database/mod.rs
+++ b/stackslib/src/clarity_vm/database/mod.rs
@@ -1232,10 +1232,24 @@ impl ClarityBackingStore for MemoryBackingStore {
         SqliteConnection::get(self.get_side_store(), key)
     }
 
+    fn get_data_from_path(&mut self, hash: &TrieHash) -> InterpreterResult<Option<String>> {
+        SqliteConnection::get(self.get_side_store(), hash.to_string().as_str())
+    }
+
     fn get_data_with_proof(&mut self, key: &str) -> InterpreterResult<Option<(String, Vec<u8>)>> {
         Ok(SqliteConnection::get(self.get_side_store(), key)?.map(|x| (x, vec![])))
     }
 
+    fn get_data_with_proof_from_path(
+        &mut self,
+        key: &TrieHash,
+    ) -> InterpreterResult<Option<(String, Vec<u8>)>> {
+        Ok(
+            SqliteConnection::get(self.get_side_store(), key.to_string().as_str())?
+                .map(|x| (x, vec![])),
+        )
+    }
+
     fn get_side_store(&mut self) -> &Connection {
         &self.side_store
     }

From 53f937b5198bf189de0ae550d2e47698186e3bac Mon Sep 17 00:00:00 2001
From: Chris Guimaraes <cguimaraes@hiro.so>
Date: Wed, 27 Nov 2024 14:23:44 +0000
Subject: [PATCH 5/6] chore: add missing dependency

---
 clarity/src/vm/database/sqlite.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clarity/src/vm/database/sqlite.rs b/clarity/src/vm/database/sqlite.rs
index 3d72a1b0fe..247861d285 100644
--- a/clarity/src/vm/database/sqlite.rs
+++ b/clarity/src/vm/database/sqlite.rs
@@ -19,7 +19,8 @@ use rusqlite::{
     params, Connection, Error as SqliteError, ErrorCode as SqliteErrorCode, OptionalExtension, Row,
     Savepoint,
 };
-use stacks_common::types::chainstate::{BlockHeaderHash, StacksBlockId};
+use stacks_common::types::chainstate::{BlockHeaderHash, StacksBlockId, TrieHash};
+
 use stacks_common::types::sqlite::NO_PARAMS;
 use stacks_common::util::db::tx_busy_handler;
 use stacks_common::util::hash::Sha512Trunc256Sum;

From b3f7bd0d7318c29b30e3ebeb0589c763e6550059 Mon Sep 17 00:00:00 2001
From: Chris Guimaraes <cguimaraes@hiro.so>
Date: Wed, 27 Nov 2024 14:31:17 +0000
Subject: [PATCH 6/6] chore: fmt

---
 clarity/src/vm/database/sqlite.rs | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clarity/src/vm/database/sqlite.rs b/clarity/src/vm/database/sqlite.rs
index 247861d285..65b4dfaea5 100644
--- a/clarity/src/vm/database/sqlite.rs
+++ b/clarity/src/vm/database/sqlite.rs
@@ -20,7 +20,6 @@ use rusqlite::{
     Savepoint,
 };
 use stacks_common::types::chainstate::{BlockHeaderHash, StacksBlockId, TrieHash};
-
 use stacks_common::types::sqlite::NO_PARAMS;
 use stacks_common::util::db::tx_busy_handler;
 use stacks_common::util::hash::Sha512Trunc256Sum;