Add Get State Proofs For Block method and StateProofsResponse for atomic inclusion proof data retrieval#3
Add Get State Proofs For Block method and StateProofsResponse for atomic inclusion proof data retrieval#3asharma13524 wants to merge 23 commits into
Conversation
146c968 to
edee422
Compare
| } | ||
| } | ||
|
|
||
| impl<N: Network> FromStr for StateProofsResponse<N> { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
| // 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)) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
3842782 to
f55927b
Compare
|
@lukenewman should be ready for another pass |
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
StateProofsResponsestruct (includes block_height, global_state_root, Vec), with full serialization and deserialization supportAdded
Ledger::get_state_proofs_for_block()method to return atomic proof data for a given block_height and list of commitmentsCreated
InMemoryStateQuerystruct implementingQueryTrait, allowing proof consumers to supply state data directly without hitting remote endpointsAdded
Query::Batchvariant to support this mode in the proverRelated PRs
puzzlehq/snarkOS#2