Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion validity/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub fn setup_proposer_logger() {
tracing_subscriber::fmt()
.with_env_filter(
tracing_subscriber::EnvFilter::from_default_env()
.add_directive(tracing::Level::INFO.into())
.add_directive("single_hint_handler=error".parse().unwrap())
.add_directive("execute=error".parse().unwrap())
.add_directive("sp1_prover=error".parse().unwrap())
Expand Down
110 changes: 109 additions & 1 deletion validity/src/proposer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,41 @@
.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 {
Ok(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));
}
Ok(false) => {
debug!(
"Aggregation request validation failed, moving to range proofs: start_block={}, end_block={}",
unreq_agg_request.start_block, unreq_agg_request.end_block
);
// Validation failed, continue to try fetching range proofs
}
Err(e) => {
warn!("Error validating aggregation request: {:?}. Moving to range proofs.", e);
// Error during validation, continue to try fetching range proofs
}
}
}

let unreq_range_request = self
Expand All @@ -623,6 +657,80 @@
Ok(None)
}

/// Validates an aggregation proof request by checking that:
/// 1. The expected range proofs exist and are complete
/// 2. There are no gaps between consecutive range proofs
/// 3. There are no duplicate/overlapping range proofs
/// 4. The range proofs cover the entire block range
pub async fn validate_aggregation_request(
&self,
range_proofs: &Vec<OPSuccinctRequest>,

Check failure on line 667 in validity/src/proposer.rs

View workflow job for this annotation

GitHub Actions / Formatting & Clippy

writing `&Vec` instead of `&[_]` involves a new object where a slice will do
agg_request: &OPSuccinctRequest,
) -> Result<bool> {
debug!(
"Validating {} aggregation proof request: start_block={}, end_block={}",
range_proofs.len(),
range_proofs.first().unwrap().start_block,
range_proofs.last().unwrap().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
Copy link
Contributor

Choose a reason for hiding this comment

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

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 Ok(false);
}

// Check for gaps and duplicates between consecutive proofs
for i in 1..range_proofs.len() {
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 Ok(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 Ok(false);
}
}

// All validation checks passed
debug!(
"Aggregation request validated successfully with {} consecutive range proofs",
range_proofs.len()
);
Ok(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<()> {
Expand Down
Loading