Skip to content

Commit bbdeda1

Browse files
committed
Simplified code, add comments
1 parent a4e4979 commit bbdeda1

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

batcher/aligned-sdk/src/sdk/aggregation.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ pub enum ProofVerificationAggModeError {
5555
///
5656
/// The step-by-step verification process includes:
5757
/// 1. Querying the blob versioned hash from the events emitted by the aligned proof aggregation service contract since `from_block`
58-
/// 2. Retrieving the corresponding beacon block using the blocks parent beacon root
58+
/// 2. Retrieving the corresponding beacon block using the block's parent beacon root
5959
/// 3. Fetching the blobs associated with that slot
6060
/// 4. Filtering the blob that matches the queried blob versioned hash
6161
/// 5. Decoding the blob to extract the proofs commitments
62-
/// 6. Checking if the given proof commitment exists within the blobs proofs
62+
/// 6. Checking if the given proof commitment exists within the blob's proofs
6363
/// 7. Reconstructing the Merkle root and verifying it against the root stored in the contract
6464
pub async fn is_proof_verified_in_aggregation_mode(
6565
verification_data: AggregationModeVerificationData,
@@ -97,6 +97,10 @@ pub async fn is_proof_verified_in_aggregation_mode(
9797
.try_into()
9898
.map_err(|_| ProofVerificationAggModeError::EventDecoding)?;
9999
let merkle_root = log.topics[1].0;
100+
101+
// Block Number shouldn't be empty, in case it is,
102+
// there is a problem with this log, and we skip it
103+
// This same logic is replicated for other checks.
100104
let Some(block_number) = log.block_number else {
101105
continue;
102106
};
@@ -141,13 +145,11 @@ pub async fn is_proof_verified_in_aggregation_mode(
141145
let proof_commitments = decoded_blob(blob_bytes);
142146

143147
if proof_commitments.contains(&verification_data.commitment()) {
144-
if verify_blob_merkle_root(proof_commitments, merkle_root) {
145-
return Ok(merkle_root);
148+
return if verify_blob_merkle_root(proof_commitments, merkle_root) {
149+
Ok(merkle_root)
146150
} else {
147-
return Err(ProofVerificationAggModeError::UnmatchedBlobAndEventMerkleRoot);
148-
}
149-
} else {
150-
continue;
151+
Err(ProofVerificationAggModeError::UnmatchedBlobAndEventMerkleRoot)
152+
};
151153
}
152154
}
153155

0 commit comments

Comments
 (0)