-
Notifications
You must be signed in to change notification settings - Fork 115
feat: validate agg #552
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
Merged
Merged
feat: validate agg #552
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
513cc90
compiles
yuwen01 7ea3ca3
remove forced inof
yuwen01 96f8433
refactor validation function
yuwen01 7c1fe1c
check that range proofs cover the entire expected
yuwen01 f53bdee
new metric + different error handling
yuwen01 e0d0695
merge main
yuwen01 8f34318
update elf
yuwen01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -602,7 +602,38 @@ where | |
| .await?; | ||
|
|
||
| if let Some(unreq_agg_request) = unreq_agg_request { | ||
| return Ok(Some(unreq_agg_request)); | ||
| // Fetch consecutive range proofs from the database associated with the aggregation | ||
| // proof request. | ||
| let range_proofs = self | ||
| .proof_requester | ||
| .db_client | ||
| .get_consecutive_complete_range_proofs( | ||
| unreq_agg_request.start_block, | ||
| unreq_agg_request.end_block, | ||
| &self.program_config.commitments, | ||
| self.requester_config.l1_chain_id, | ||
| self.requester_config.l2_chain_id, | ||
| ) | ||
| .await?; | ||
|
|
||
| // Validate the aggregation proof request | ||
| match self.validate_aggregation_request(&range_proofs, &unreq_agg_request).await { | ||
| true => { | ||
| debug!( | ||
| "Aggregation request validated successfully: start_block={}, end_block={}", | ||
| unreq_agg_request.start_block, unreq_agg_request.end_block | ||
| ); | ||
| return Ok(Some(unreq_agg_request)); | ||
| } | ||
| false => { | ||
| debug!( | ||
| "Aggregation request validation failed, moving to range proofs: start_block={}, end_block={}", | ||
| unreq_agg_request.start_block, unreq_agg_request.end_block | ||
| ); | ||
| ValidityGauge::AggProofValidationErrorCount.increment(1.0); | ||
| // Validation failed, continue to try fetching range proofs | ||
| } | ||
| } | ||
| } | ||
|
|
||
| let unreq_range_request = self | ||
|
|
@@ -623,6 +654,104 @@ where | |
| Ok(None) | ||
| } | ||
|
|
||
| /// Validates an aggregation proof request by checking that: | ||
| /// 1. There are no gaps between consecutive range proofs | ||
| /// 2. There are no duplicate/overlapping range proofs | ||
| /// 3. The range proofs cover the entire block range | ||
| pub async fn validate_aggregation_request( | ||
| &self, | ||
| range_proofs: &[OPSuccinctRequest], | ||
| agg_request: &OPSuccinctRequest, | ||
| ) -> bool { | ||
| debug!( | ||
| "Validating aggregation proof request: start_block={}, end_block={}", | ||
| agg_request.start_block, agg_request.end_block | ||
| ); | ||
|
|
||
| // Log all constituent range proofs | ||
| for (i, proof) in range_proofs.iter().enumerate() { | ||
| debug!( | ||
| "Range proof {}: start_block={}, end_block={}", | ||
| i, proof.start_block, proof.end_block | ||
| ); | ||
| } | ||
|
|
||
| // If no range proofs found, validation fails | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to https://github.com/succinctlabs/op-succinct/blob/main/validity/src/proposer.rs#L392 this can not happen |
||
| if range_proofs.is_empty() { | ||
| warn!( | ||
| start_block = ?agg_request.start_block, | ||
| end_block = ?agg_request.end_block, | ||
| commitments = ?self.program_config.commitments, | ||
| "No consecutive span proof range found for request" | ||
| ); | ||
| return false; | ||
| } | ||
|
|
||
| let first_range_proof_request = | ||
| range_proofs.first().expect("Range proofs should not be empty"); | ||
|
|
||
| let last_range_proof_request = | ||
| range_proofs.last().expect("Range proofs should not be empty"); | ||
|
|
||
| if first_range_proof_request.start_block != agg_request.start_block { | ||
| warn!( | ||
| expected_start_block = ?agg_request.start_block, | ||
| actual_start_block = ?first_range_proof_request.start_block, | ||
| commitments = ?self.program_config.commitments, | ||
| "Range proofs start block does not match aggregation request" | ||
| ); | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| if last_range_proof_request.end_block != agg_request.end_block { | ||
| warn!( | ||
| expected_end_block = ?agg_request.end_block, | ||
| actual_end_block = ?last_range_proof_request.end_block, | ||
| commitments = ?self.program_config.commitments, | ||
| "Range proofs end block does not match aggregation request" | ||
| ); | ||
| return false; | ||
| } | ||
|
|
||
| // Check for gaps and duplicates / overlaps between consecutive proofs | ||
| for i in 1..range_proofs.len() { | ||
fakedev9999 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| let prev_proof = &range_proofs[i - 1]; | ||
| let curr_proof = &range_proofs[i]; | ||
|
|
||
| // Check for gap | ||
| if prev_proof.end_block != curr_proof.start_block { | ||
| debug!( | ||
| "Gap detected: proof {} ends at {} but proof {} starts at {}", | ||
| i - 1, | ||
| prev_proof.end_block, | ||
| i, | ||
| curr_proof.start_block | ||
| ); | ||
| return false; | ||
| } | ||
|
|
||
| // Check for overlap (duplicate blocks) | ||
| if prev_proof.end_block > curr_proof.start_block { | ||
| debug!( | ||
| "Overlap detected: proof {} ends at {} but proof {} starts at {}", | ||
| i - 1, | ||
| prev_proof.end_block, | ||
| i, | ||
| curr_proof.start_block | ||
| ); | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| // All validation checks passed | ||
| debug!( | ||
| "Aggregation request validated successfully with {} consecutive range proofs", | ||
| range_proofs.len() | ||
| ); | ||
| true | ||
| } | ||
|
|
||
| /// Relay all completed aggregation proofs to the contract. | ||
| #[tracing::instrument(name = "proposer.submit_agg_proofs", skip(self))] | ||
| async fn submit_agg_proofs(&self) -> Result<()> { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.