2 releases
0.1.1 | Oct 28, 2024 |
---|---|
0.1.0 | Oct 28, 2024 |
#2445 in Data structures
304 downloads per month
Used in hdp
30KB
631 lines
sn-trie-proofs
A comprehensive transaction/receipt inclusion proofs handler for Starknet trie. Tested with various versions including v0.12.3 ~ v 0.13.2. This library exposes various proof building functionalities, verification, trie construction etc.
Installation
Add dependency sn-trie-proofs
to your project:
sn-trie-proofs = { git = "https://github.com/HerodotusDev/trie-proofs.git" }
Usage
- Transaction Trie Handler
#[tokio::test]
async fn test_build_tx_tree_from_block_3() {
let mut handler = TxsMptHandler::new(PATHFINDER_URL).unwrap();
// # 0.13.1.1
let block_number = 70015;
handler
.build_tx_tree_from_block(block_number)
.await
.unwrap();
let proof = handler.get_proof(0).unwrap();
let membership: Membership = handler.verify_proof(0, proof).unwrap();
assert!(membership.is_member());
}
- Transaction Receipt Trie Handler
Currently we only supporting receipt trie after 0.13.2 version.
#[tokio::test]
async fn test_build_tx_tree_from_block_4() {
let mut handler = TxReceiptsMptHandler::new(PATHFINDER_URL).unwrap();
// # 0.13.2
let block_number = 99708;
handler
.build_tx_receipts_tree_from_block(block_number)
.await
.unwrap();
let proof = handler.get_proof(0).unwrap();
let membership: Membership = handler.verify_proof(0, proof).unwrap();
assert!(membership.is_member());
}
Credit
For trie implementation, this project depends on the sn-merkle-trie, code is mostly from pathfinder's merkle tree implementation.
For transaction and transaction receipt types, using types-rs.
License
sn-trie-proofs
is licensed under the GNU General Public License v3.0.
Herodotus Dev Ltd - 2024
Dependencies
~11–23MB
~338K SLoC