Skip to content

Commit 04298af

Browse files
feat: regenerate photon-api crate & v2 proof handling (#1753)
* feat: regenerate photon-api crate * refactor: remove debug print statement from get_validity_proof_v2 * feat: enable indexer in LightValidatorConfig for address tree initialization * refactor: disable adjust address root index calculation in types.rs * feat: update photon dependency to a newer commit * rename AddressSeq to AddressQueueIndex and update related references * refactor: implement Display trait for AccountState and update formatting * rename: change AddressSeq to AddressQueueIndex and update module references * refactor: change nullifier_queue_index and tree_type to u16 in AccountContext
1 parent d4e4528 commit 04298af

15 files changed

+127
-1218
lines changed

forester/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ light-merkle-tree-reference = { workspace = true }
2020
light-registry = { workspace = true }
2121
photon-api = { workspace = true }
2222
forester-utils = { workspace = true }
23-
light-client = { workspace = true }
23+
light-client = { workspace = true, features = ["v2"] }
2424
light-merkle-tree-metadata = { workspace = true }
2525
light-sdk = { workspace = true, features = ["anchor"] }
2626
light-program-test = { workspace = true }

forester/tests/address_v2_test.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use light_compressed_account::{
2525
},
2626
};
2727
use light_compressed_token::process_transfer::transfer_sdk::to_account_metas;
28-
use light_program_test::{accounts::test_accounts::TestAccounts, indexer::TestIndexer, Indexer};
28+
use light_program_test::{accounts::test_accounts::TestAccounts, Indexer};
2929
use light_prover_client::gnark::helpers::{LightValidatorConfig, ProverConfig};
3030
use light_test_utils::create_address_test_program_sdk::{
3131
create_pda_instruction, CreateCompressedPdaInstructionInputs,
@@ -289,11 +289,12 @@ async fn create_v2_addresses<R: RpcConnection + MerkleTreeExt + Indexer>(
289289
tree: *batch_address_merkle_tree,
290290
})
291291
.collect::<Vec<_>>();
292-
let test_indexer = TestIndexer::init_from_acounts(rpc.get_payer(), env, 50).await;
293-
let proof_result = test_indexer
292+
293+
let proof_result = rpc
294294
.get_validity_proof_v2(Vec::new(), address_with_trees)
295295
.await
296296
.unwrap();
297+
297298
if num_addresses == 1 {
298299
let data: [u8; 31] = [1; 31];
299300
let new_address_params = NewAddressParams {
@@ -303,13 +304,11 @@ async fn create_v2_addresses<R: RpcConnection + MerkleTreeExt + Indexer>(
303304
address_merkle_tree_root_index: proof_result.address_root_indices[0],
304305
};
305306

306-
let proof = proof_result.proof;
307-
308307
let create_ix_inputs = CreateCompressedPdaInstructionInputs {
309308
data,
310309
signer: &payer.pubkey(),
311310
output_compressed_account_merkle_tree_pubkey: &env.v1_state_trees[0].merkle_tree,
312-
proof: &proof.unwrap(),
311+
proof: &proof_result.proof.unwrap(),
313312
new_address_params,
314313
registered_program_pda,
315314
};

scripts/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ install_rust() {
102102
export PATH="${PREFIX}/cargo/bin:${PATH}"
103103
rustup component add --toolchain 1.83-x86_64-unknown-linux-gnu clippy
104104
cargo install cargo-expand --locked
105-
cargo install --git https://github.com/Lightprotocol/photon.git --rev edff82c5cb7fd891b5ab62faed9126594c97d90b --locked
105+
cargo install --git https://github.com/Lightprotocol/photon.git --rev 41ac9d0e3607a820ef1dbf4312b288992f792864 --locked
106106
log "rust"
107107
fi
108108
}

sdk-libs/client/src/indexer/photon_indexer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,14 +776,13 @@ impl Indexer for PhotonIndexer {
776776
}),
777777
..Default::default()
778778
};
779-
780779
let result = photon_api::apis::default_api::get_validity_proof_v2_post(
781780
&self.configuration,
782781
request,
783782
)
784783
.await?;
785784
let result = Self::extract_result("get_validity_proof_v2", result.result)?;
786-
super::types::ProofRpcResultV2::from_api_model(*result.value, hashes.len())
785+
super::types::ProofRpcResultV2::from_api_model(*result.value)
787786
})
788787
.await
789788
}

sdk-libs/client/src/indexer/types.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl ProofRpcResult {
109109
#[derive(Debug, Default, Clone)]
110110
pub struct ProofRpcResultV2 {
111111
pub proof: Option<CompressedProof>,
112-
// If none -> proof by index and not included in zkp, else included in zkp
112+
// If none -> proof by index and not included in zkp, else included in zkp
113113
pub root_indices: Vec<Option<u16>>,
114114
pub address_root_indices: Vec<u16>,
115115
}
@@ -118,7 +118,6 @@ pub struct ProofRpcResultV2 {
118118
impl ProofRpcResultV2 {
119119
pub fn from_api_model(
120120
value: photon_api::models::CompressedProofWithContextV2,
121-
num_hashes: usize,
122121
) -> Result<Self, IndexerError> {
123122
let proof = if let Some(proof) = value.compressed_proof {
124123
let proof = CompressedProof {
@@ -142,17 +141,19 @@ impl ProofRpcResultV2 {
142141

143142
Ok(Self {
144143
proof,
145-
root_indices: value.root_indices[..num_hashes]
144+
root_indices: value
145+
.accounts
146146
.iter()
147147
.map(|x| {
148-
if x.prove_by_index {
148+
if x.root_index.prove_by_index {
149149
None
150150
} else {
151-
Some(x.root_index)
151+
Some(x.root_index.root_index as u16)
152152
}
153153
})
154154
.collect::<Vec<Option<u16>>>(),
155-
address_root_indices: value.root_indices[num_hashes..]
155+
address_root_indices: value
156+
.addresses
156157
.iter()
157158
.map(|x| x.root_index)
158159
.collect::<Vec<u16>>(),

0 commit comments

Comments
 (0)