Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update get_proof_for()to fetch TreeVersion by item status #807

Closed
wants to merge 1 commit into from

Conversation

0xKitsune
Copy link
Contributor

Currently when fetching an inclusion proof for a given TreeItem, the latest tree is used regardless of item status.

    pub fn get_proof_for(&self, item: &TreeItem) -> (Field, InclusionProof) {
        let (leaf, root, proof) = self.latest.get_leaf_and_proof(item.leaf_index);

        let proof = InclusionProof {
            root: Some(root),
            proof: Some(proof),
            message: None,
        };

        (leaf, proof)
    }

This PR introduces logic to serve inclusion proofs based on item status.

    pub fn get_proof_for(&self, item: &TreeItem) -> (Field, InclusionProof) {
        let (leaf, root, proof) = match item.status {
            ProcessedStatus::Processed | ProcessedStatus::Mined => {
                self.processed.get_leaf_and_proof(item.leaf_index)
            }
            ProcessedStatus::Pending => self.latest.get_leaf_and_proof(item.leaf_index),
        };

        let proof = InclusionProof {
            root: Some(root),
            proof: Some(proof),
            message: None,
        };

        (leaf, proof)
    }

@0xKitsune 0xKitsune requested a review from a team as a code owner October 26, 2024 23:58
@0xKitsune 0xKitsune marked this pull request as draft October 27, 2024 00:12
@@ -259,7 +259,7 @@ impl OnChainIdentityProcessor {
)
.await
.map_err(|e| {
error!(?e, "Failed to insert identity to contract.");
error!(?e, "Failed to insert identity to contract.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
error!(?e, "Failed to insert identity to contract.");
error!(?e, "Failed to insert identity to contract.");

@piohei
Copy link
Contributor

piohei commented Oct 31, 2024

Closing as it was done in different PR. :)

@piohei piohei closed this Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants