Skip to content

Commit

Permalink
Remove labels_per_unit from ProofMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
poszu committed Nov 9, 2023
1 parent 4d14816 commit 2f546b7
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 21 deletions.
2 changes: 1 addition & 1 deletion certifier/tests/test_certify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async fn test_certificate_post_proof() {

// Try to certify with an invalid proof
let mut invalid_req = req;
invalid_req.metadata.labels_per_unit = 2;
invalid_req.metadata.num_units = 8;
let response = client
.post(format!("http://{addr}/certify"))
.json(&invalid_req)
Expand Down
2 changes: 0 additions & 2 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ pub struct ProofMetadata {
#[serde_as(as = "Base64")]
pub challenge: [u8; 32],
pub num_units: u32,
pub labels_per_unit: u64,
}

impl ProofMetadata {
Expand All @@ -81,7 +80,6 @@ impl ProofMetadata {
node_id: post_metadata.node_id,
commitment_atx_id: post_metadata.commitment_atx_id,
num_units: post_metadata.num_units,
labels_per_unit: post_metadata.labels_per_unit,
}
}
}
Expand Down
18 changes: 0 additions & 18 deletions src/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ pub enum MetadataValidationError {
NumUnitsTooSmall { min: u32, got: u32 },
#[error("numunits too large: {got} < {max}")]
NumUnitsTooLarge { max: u32, got: u32 },
#[error("invalid labels_per_unit: {got} != {expected}")]
LabelsPerUnitInvalid { expected: u64, got: u64 },
}

pub fn verify_metadata(
Expand All @@ -113,12 +111,6 @@ pub fn verify_metadata(
got: metadata.num_units,
});
}
if metadata.labels_per_unit != init_cfg.labels_per_unit {
return Err(MetadataValidationError::LabelsPerUnitInvalid {
expected: init_cfg.labels_per_unit,
got: metadata.labels_per_unit,
});
}
Ok(())
}

Expand Down Expand Up @@ -301,7 +293,6 @@ mod tests {
commitment_atx_id: [0; 32],
challenge: [0; 32],
num_units: 10,
labels_per_unit: 2048,
};
let mut pow_verifier = Box::new(MockPowVerifier::new());
pow_verifier
Expand Down Expand Up @@ -341,7 +332,6 @@ mod tests {
commitment_atx_id: [0u8; 32],
challenge: [0u8; 32],
num_units: 10,
labels_per_unit: 2048,
};
let mut pow_verifier = Box::new(MockPowVerifier::new());
pow_verifier
Expand Down Expand Up @@ -397,7 +387,6 @@ mod tests {
commitment_atx_id: [0; 32],
challenge: [0; 32],
num_units: 1,
labels_per_unit: 100,
};
let init_cfg = InitConfig {
min_num_units: 1,
Expand All @@ -420,12 +409,5 @@ mod tests {
};
assert!(super::verify_metadata(&num_units_large, &init_cfg).is_err());
}
{
let invalid_labels_per_unit = ProofMetadata {
labels_per_unit: 99,
..valid_meta
};
assert!(super::verify_metadata(&invalid_labels_per_unit, &init_cfg).is_err());
}
}
}

0 comments on commit 2f546b7

Please sign in to comment.