From 60d523194af0f2f45031405b88a975ce2ad1d3d5 Mon Sep 17 00:00:00 2001 From: Ammar Arif Date: Tue, 7 Jan 2025 17:59:29 -0500 Subject: [PATCH 1/3] feat: change to poseidon hash --- crates/katana/rpc/rpc/tests/proofs.rs | 2 +- crates/katana/trie/src/classes.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/katana/rpc/rpc/tests/proofs.rs b/crates/katana/rpc/rpc/tests/proofs.rs index 66268a42ea..c07a8a21ba 100644 --- a/crates/katana/rpc/rpc/tests/proofs.rs +++ b/crates/katana/rpc/rpc/tests/proofs.rs @@ -122,7 +122,7 @@ async fn genesis_states() { let classes_proof = MultiProof::from(proofs.classes_proof.nodes); let classes_tree_root = proofs.global_roots.classes_tree_root; - let classes_verification_result = katana_trie::verify_proof::( + let classes_verification_result = katana_trie::verify_proof::( &classes_proof, classes_tree_root, genesis_classes, diff --git a/crates/katana/trie/src/classes.rs b/crates/katana/trie/src/classes.rs index e2481c7dcd..ff71e3b3b8 100644 --- a/crates/katana/trie/src/classes.rs +++ b/crates/katana/trie/src/classes.rs @@ -1,10 +1,9 @@ use bonsai_trie::{BonsaiDatabase, BonsaiPersistentDatabase, MultiProof}; use katana_primitives::block::BlockNumber; use katana_primitives::class::{ClassHash, CompiledClassHash}; -use katana_primitives::hash::Pedersen; +use katana_primitives::hash::{Poseidon, StarkHash}; use katana_primitives::Felt; use starknet::macros::short_string; -use starknet_types_core::hash::{Poseidon, StarkHash}; use crate::id::CommitId; @@ -15,7 +14,7 @@ impl ClassesMultiProof { // TODO: maybe perform results check in this method as well. make it accept the compiled class // hashes pub fn verify(&self, root: Felt, class_hashes: Vec) -> Vec { - crate::verify_proof::(&self.0, root, class_hashes) + crate::verify_proof::(&self.0, root, class_hashes) } } @@ -27,7 +26,7 @@ impl From for ClassesMultiProof { #[derive(Debug)] pub struct ClassesTrie { - trie: crate::BonsaiTrie, + trie: crate::BonsaiTrie, } ////////////////////////////////////////////////////////////// From ed6ed02e623ac708850eeca2509e04c001fd6717 Mon Sep 17 00:00:00 2001 From: Ammar Arif Date: Tue, 7 Jan 2025 18:35:16 -0500 Subject: [PATCH 2/3] fix all references --- crates/katana/storage/db/src/trie/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/katana/storage/db/src/trie/mod.rs b/crates/katana/storage/db/src/trie/mod.rs index fce7968a24..4bb4a6d54d 100644 --- a/crates/katana/storage/db/src/trie/mod.rs +++ b/crates/katana/storage/db/src/trie/mod.rs @@ -388,7 +388,7 @@ fn to_db_key(key: &DatabaseKey<'_>) -> models::trie::TrieDatabaseKey { #[cfg(test)] mod tests { - use katana_primitives::hash::{Pedersen, StarkHash}; + use katana_primitives::hash::{Pedersen, Poseidon, StarkHash}; use katana_primitives::{felt, hash}; use katana_trie::{verify_proof, ClassesTrie, CommitId}; use starknet::macros::short_string; @@ -447,7 +447,7 @@ mod tests { let proofs0 = snapshot0.multiproof(vec![felt!("0x9999")]); let verify_result0 = - verify_proof::(&proofs0, snapshot_root0, vec![felt!("0x9999")]); + verify_proof::(&proofs0, snapshot_root0, vec![felt!("0x9999")]); let value = hash::Poseidon::hash(&short_string!("CONTRACT_CLASS_LEAF_V0"), &felt!("0xdead")); @@ -464,7 +464,7 @@ mod tests { let proofs1 = snapshot1.multiproof(vec![felt!("0x6969")]); let verify_result1 = - verify_proof::(&proofs1, snapshot_root1, vec![felt!("0x6969")]); + verify_proof::(&proofs1, snapshot_root1, vec![felt!("0x6969")]); let value = hash::Poseidon::hash(&short_string!("CONTRACT_CLASS_LEAF_V0"), &felt!("0x80085")); @@ -475,7 +475,7 @@ mod tests { let root = trie.root(); let proofs = trie.multiproof(vec![felt!("0x6969"), felt!("0x9999")]); let result = - verify_proof::(&proofs, root, vec![felt!("0x6969"), felt!("0x9999")]); + verify_proof::(&proofs, root, vec![felt!("0x6969"), felt!("0x9999")]); let value0 = hash::Poseidon::hash(&short_string!("CONTRACT_CLASS_LEAF_V0"), &felt!("0x80085")); From 95a7c1265b089a78b48359fd607d80358f38817c Mon Sep 17 00:00:00 2001 From: Ammar Arif Date: Tue, 7 Jan 2025 23:00:05 -0500 Subject: [PATCH 3/3] clippy --- crates/katana/storage/db/src/trie/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/katana/storage/db/src/trie/mod.rs b/crates/katana/storage/db/src/trie/mod.rs index 4bb4a6d54d..7301b66dc4 100644 --- a/crates/katana/storage/db/src/trie/mod.rs +++ b/crates/katana/storage/db/src/trie/mod.rs @@ -388,7 +388,7 @@ fn to_db_key(key: &DatabaseKey<'_>) -> models::trie::TrieDatabaseKey { #[cfg(test)] mod tests { - use katana_primitives::hash::{Pedersen, Poseidon, StarkHash}; + use katana_primitives::hash::{Poseidon, StarkHash}; use katana_primitives::{felt, hash}; use katana_trie::{verify_proof, ClassesTrie, CommitId}; use starknet::macros::short_string;