Skip to content

Commit e200e80

Browse files
committed
fix(zk-id): V1 state tree for accounts (immediate merkle proof) + V2 address tree; register localnet V1 state tree
1 parent ac0a8d3 commit e200e80

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

zk/zk-id/tests/test.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ use light_client::{
1111
};
1212
use light_hasher::{hash_to_field_size::hash_to_bn254_field_size_be, Hasher, Poseidon, Sha256};
1313
use light_sdk::{
14-
address::v1::derive_address,
14+
address::v2::derive_address,
1515
instruction::{PackedAccounts, SystemAccountMetaConfig},
1616
};
1717
use num_bigint::BigUint;
1818
use solana_instruction::Instruction;
1919
use solana_keypair::Keypair;
20-
use solana_pubkey::Pubkey;
20+
use solana_pubkey::{pubkey, Pubkey};
2121
use solana_signature::Signature;
2222
use solana_signer::Signer;
23+
use light_sdk_types::lca::TreeType;
2324
use zk_id::{CREDENTIAL, ISSUER, ZK_ID_CHECK};
2425

2526
/// Starts `light test-validator` (Solana test validator + Photon indexer + Light
@@ -68,6 +69,19 @@ async fn start_validator_and_connect() -> LightClient {
6869
tokio::time::sleep(Duration::from_secs(1)).await;
6970
}
7071

72+
// The client is built with the `v2` feature, which only exposes V2 batched
73+
// state trees. zk-id stores its accounts in the localnet V1 (concurrent)
74+
// state tree so their merkle proofs are available immediately (no forester /
75+
// batch needed for `verify_credential`). Register it so V1 state-tree lookups
76+
// resolve. Addresses still use the V2 address tree.
77+
rpc.state_merkle_trees.push(TreeInfo {
78+
tree: pubkey!("smt1NamzXdq4AMqS2fS2F1i5KTYPZRhoHgWx38d8WsT"),
79+
queue: pubkey!("nfq1NvQDJ2GEgnS8zt9prAe8rjjpAW1zFkrvZoBR148"),
80+
cpi_context: Some(pubkey!("cpi1uHzrEhBG733DoEJNgHCyRS3XmmyVNZx5fonubE4")),
81+
next_tree_info: None,
82+
tree_type: TreeType::StateV1,
83+
});
84+
7185
rpc
7286
}
7387

@@ -160,7 +174,7 @@ async fn test_create_issuer_and_add_credential() {
160174
.await
161175
.unwrap();
162176

163-
let address_tree_info = rpc.get_address_tree_v1();
177+
let address_tree_info = rpc.get_address_tree_v2();
164178

165179
let (issuer_address, _) = derive_address(
166180
&[ISSUER, payer.pubkey().as_ref()],

0 commit comments

Comments
 (0)