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

feat(proof): pathfinder_getClassProof endpoint #2179

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

odesenfans
Copy link

Added a new endpoint pathfinder/v0.1/pathfinder_getClassProof that returns the Merkle proof of any class hash in the class trie.


This new endpoint is necessary to run the Starknet OS to completion as we need the full class commitment as input of the OS.

@odesenfans odesenfans requested a review from a team as a code owner August 21, 2024 11:42
Copy link
Contributor

@sistemd sistemd left a comment

Choose a reason for hiding this comment

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

I see nothing objectionable, but @kkovaacs is our trie expert.

Also not sure if something like this will be in the v0.8 spec maybe, so this endpoint won't be necessary anymore. There's a PR open for this in the specs repo. (I understand you may already be aware of this.)

@sistemd sistemd requested a review from kkovaacs August 22, 2024 20:09
Comment on lines +115 to +136
fn leaf(&self, path: &BitSlice<u8, Msb0>) -> anyhow::Result<Option<Felt>> {
assert!(path.len() == 251);

let Some(block) = self.block else {
return Ok(None);
};

let sierra =
ClassHash(Felt::from_bits(path).context("Mapping leaf path to contract address")?);

let casm = self
.tx
.casm_hash_at(block.into(), sierra)
.context("Querying CASM hash")?;
let Some(casm) = casm else {
return Ok(None);
};

let value = self.tx.class_commitment_leaf(block, &casm)?.map(|x| x.0);

Ok(value)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, this seems a bit strange. How is this actually different from ClassStorage::leaf()?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

It's not, it's an artifact from earlier attempts. Will remove it.

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.

4 participants