Skip to content

Add Get State Proofs For Block method and StateProofsResponse for atomic inclusion proof data retrieval#3

Open
asharma13524 wants to merge 23 commits into
stagingfrom
proofs-testnetv3.4.1
Open

Add Get State Proofs For Block method and StateProofsResponse for atomic inclusion proof data retrieval#3
asharma13524 wants to merge 23 commits into
stagingfrom
proofs-testnetv3.4.1

Conversation

@asharma13524

@asharma13524 asharma13524 commented Mar 20, 2025

Copy link
Copy Markdown

Motivation

Inclusion proofs fail intermittently when global_state_root, block_height, and state_paths are fetched from different blocks due to chain progression. This leads to mismatches like:

"Inclusion expected the global state root to be the same across iterations."

To address this, we now support fetching all proof dependencies atomically from a single block via a new query type and endpoint.

Test Plan

  • Introduced StateProofsResponse struct (includes block_height, global_state_root, Vec), with full serialization and deserialization support

  • Added Ledger::get_state_proofs_for_block() method to return atomic proof data for a given block_height and list of commitments

  • Created InMemoryStateQuery struct implementing QueryTrait, allowing proof consumers to supply state data directly without hitting remote endpoints

  • Added Query::Batch variant to support this mode in the prover

Related PRs

puzzlehq/snarkOS#2

@asharma13524 asharma13524 changed the base branch from testnet3 to mainnet-staging March 25, 2025 17:24
@asharma13524 asharma13524 changed the base branch from mainnet-staging to mainnet March 25, 2025 17:24
@asharma13524 asharma13524 changed the base branch from mainnet to testnet March 31, 2025 17:26
@asharma13524 asharma13524 force-pushed the proofs-testnetv3.4.1 branch from 146c968 to edee422 Compare April 10, 2025 14:43
@asharma13524 asharma13524 changed the title Proofs testnetv3.4.1 Add get_state_proofs_for_block method and StateProofsResponse for atomic inclusion proof data retrieval May 1, 2025
@asharma13524 asharma13524 changed the title Add get_state_proofs_for_block method and StateProofsResponse for atomic inclusion proof data retrieval Add Get State Proofs For Block method and StateProofsResponse for atomic inclusion proof data retrieval May 1, 2025
@asharma13524 asharma13524 marked this pull request as ready for review May 1, 2025 19:22
Comment thread console/program/src/state_path/parse.rs Outdated
}
}

impl<N: Network> FromStr for StateProofsResponse<N> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

i think we should mirror how other structs are ser/de in snarkVM -- for example, take a look at Header (ledger/block/src/header -- string.rs, serialize.rs, etc) -- i am also unaware of any reasons you took this approach, so please feel free to push back.

@asharma13524 asharma13524 May 12, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

hmm can't remember exactly why I went this way maybe just for simplicity but agreed. I'll look into refactoring StateProofsResponse to follow the general pattern

Comment thread ledger/src/get.rs
// 2. Generate proofs for each commitment
let state_paths: Vec<StatePath<N>> = commitments
.iter()
.map(|commitment| self.vm().block_store().get_state_path_for_commitment(commitment))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

does get_state_path_for_commitment calculate these based on the current block height? curious if the global_state_root (in which the block_height is specified) would potentially mismatch with these state paths if so

@asharma13524 asharma13524 May 12, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

So get_state_path_for_commitment gets the state path from the block that contains the commitment, not the passed in n block height. As long as all commitments existed at or before the block_height passed in, the state_paths and global_state_root shouldn't have a mismatch case

@asharma13524 asharma13524 force-pushed the proofs-testnetv3.4.1 branch from 3842782 to f55927b Compare May 13, 2025 15:51
@asharma13524

Copy link
Copy Markdown
Author

@lukenewman should be ready for another pass

@lukenewman lukenewman changed the base branch from testnet to staging June 27, 2025 15:24
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.

2 participants